<link href="/public/admin/css/goods.css" rel="stylesheet">
<script src="/public/common/ajaxfileupload.js"></script>
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox-content">
                <div class="row">
                    <form action="<?=url('group.goods/create')?>" id="form-create" method="post" class="form-horizontal" role="form">
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span
                                    class="c-red">*</span>商品分类：</label>
                            <div class="col-sm-9">
                                <select class="form-control m-b" name="category_id" id="category_id">
                                    <option value="0">请选择</option>
                                    <?php foreach($category as $val)  { ?>
                                        <option value="<?=$val->category_id?>"><?=$val->category_name?></option>
                                    <?php } ?>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span
                                    class="c-red">*</span>商品名称：</label>
                            <div class="col-sm-9">
                                <input type="text" value="<?=isset($detail->goods_name)?$detail->goods_name:''?>"
                                       placeholder="吸引眼球的重中之重" id="goods_name" name="goods_name" class="form-control"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span
                                    class="c-red">*</span>市场原价：</label>
                            <div class="col-sm-9">
                                <input type="text" value="<?=isset($detail->price)? $detail->price:''?>" placeholder="这个商品的市场价多少 不介入计算 界面为灰色"
                                       id="price" name="price" class="form-control"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span
                                    class="c-red">*</span>拼团价：</label>
                            <div class="col-sm-9">
                                <input type="text" value="<?=isset($detail->group_price)?$detail->group_price:''?>"
                                       placeholder="参团的价格" id="group_price" name="group_price" class="form-control"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span
                                    class="c-red">*</span>单独购买价格：</label>
                            <div class="col-sm-9">
                                <input type="text" value="<?=isset($detail->alone_price)?$detail->alone_price:''?>"
                                       placeholder="单独买的价格" id="alone_price" name="alone_price" class="form-control"/>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span class="c-red">*</span>服务承诺：</label>
                            <div class="col-sm-9">
                                <div class="checkbox i-checks">
                                    <?php $i=0; foreach(config('dataattr.group') as $val) {$i++;?>
                                    <label style="width: 360px;"><input type="checkbox" name="service[]" value="<?=$val['id']?>" > <i></i><?=$val['title']?> (<?=$val['detail']?>) </label>
                                    <?=$i%3 == 0 ? '</br>' : '';?>
                                    <?php } ?>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label"><span class="c-red">*</span>开团时间：</label>
                            <div class="col-sm-9">
                                <input placeholder="只有已经开始的团购才显示在列表" value="<?=isset($detail->bg_time)?date('Y-m-d H:i:s',$detail->bg_time):''?>" name="bg_time" id="bg_time" class="laydate-icon form-control layer-date">
                            </div>
                        </div>
                        <script>
                            laydate({
                                elem: '#bg_time',
                                event: 'focus',
                                format: 'YYYY-MM-DD hh:mm:ss',
                                istime: true
                            });
                        </script>
                        <div class="form-group">
                            <label class="col-sm-3 control-label"><span class="c-red">*</span>结束时间：</label>
                            <div class="col-sm-9">
                                <input placeholder="结束后就不能预定了" value="<?=isset($detail->end_time)?date('Y-m-d H:i:s',$detail->end_time):''?>" name="end_time" id="end_time" class="laydate-icon form-control layer-date">
                            </div>
                        </div>
                        <script>
                            laydate({
                                elem: '#end_time',
                                event: 'focus',
                                format: 'YYYY-MM-DD hh:mm:ss',
                                istime: true
                            });
                        </script>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span class="c-red">*</span>几人团：</label>
                            <div class="col-sm-9">
                                <input type="text" value="<?=isset($detail->group_num)?$detail->group_num:''?>" placeholder="这是一个几人团 " id="group_num" name="group_num" class="form-control"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right">以参团人数：</label>
                            <div class="col-sm-9">
                                <input type="text" value="<?=isset($detail->people_num)?$detail->people_num:''?>"
                                       placeholder="这里设置假的已参团人数 当然也会真实增长 用来营销 " id="people_num" name="people_num" class="form-control"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span
                                    class="c-red">*</span>剩余库存：</label>
                            <div class="col-sm-9">
                                <input type="text" value="<?=isset($detail->surplus_num)?$detail->surplus_num:''?>"
                                       placeholder="只有发货后会减少库存 库存为0时 则显示 已售空 Tips：要比实际库存小哦 以防止 已经成团后无货" id="surplus_num" name="surplus_num" class="form-control"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span
                                    class="c-red">*</span>商品简略：</label>
                            <div class="col-sm-9">
                                <textarea  name="brief" placeholder="商品简略快速了解你的商品在详情第一眼看到的就是这个简略" id="brief" cols="50" rows="10"
                                          class="form-control"><?=isset($detail->brief)?$detail->brief:''?></textarea>

                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span
                                    class="c-red">*</span>规格：</label>
                            <div class="col-sm-9">
                                <textarea name="spec" placeholder="请输入该产品的规格 如：机身颜色 黑色机身长度（mm）156.2机身宽度（mm）76.2 （回车是有效的哦）" id="spec" cols="50" rows="10"
                                          class="form-control"><?=isset($detail->spec)?$detail->spec:''?></textarea>

                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span
                                    class="c-red">*</span>包装：</label>
                            <div class="col-sm-9">
                                <textarea name="ctn" placeholder="产品的包装 如：包装清单 主机 x1	充电头 x1	数据线 x1	耳机 x1	SIM卡工具 x1	说明书 x1	保修卡 x1	安全说明 x1" id="ctn" cols="50" rows="10"
                                          class="form-control"><?=isset($detail->ctn)?$detail->ctn:''?></textarea>

                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right">是否上架：</label>
                            <div class="col-sm-9">
                                <div class="radio i-checks">
                                    <label>
                                        <input name="is_online" id="is_online" value="1"
                                               type="radio" <?php if(isset($detail->is_online)&&
                                        $detail->is_online==1){?>checked="checked"<?php }?> > <i></i> 是</label>
                                    <label>
                                        <input name="is_online" id="is_online" value="0"
                                               type="radio" <?php if(isset($detail->is_online)&&
                                        $detail->is_online==0){?>checked="checked"<?php }?> > <i></i> 否</label>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right">是否包邮：</label>
                            <div class="col-sm-9">
                                <div class="radio i-checks">
                                    <label>
                                        <input name="is_mail" id="is_mail" value="1"
                                               type="radio" <?php if(isset($detail->is_mail)&&
                                        $detail->is_mail==1){?>checked="checked"<?php }?> > <i></i> 是</label>
                                    <label>
                                        <input name="is_mail" id="is_mail" value="0"
                                               type="radio" <?php if(isset($detail->is_mail)&&
                                        $detail->is_mail==0){?>checked="checked"<?php }?> > <i></i> 否</label>
                                </div>
                            </div>
                        </div>
                        <div  class="form-group">
                            <label class="col-sm-3 control-label no-padding-right">邮费价格：</label>
                            <div class="col-sm-9">
                                <input type="text" value="<?=isset($detail->mail_price)?$detail->mail_price:''?>"
                                       placeholder="如果不包邮 请输入需要的邮费" id="mail_price" name="mail_price" class="form-control"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right">排序：</label>
                            <div class="col-sm-9">
                                <input type="text" value="<?=isset($detail->orderby)?$detail->orderby:''?>"
                                       placeholder="数字越大排序越靠前" id="orderby" name="orderby" class="form-control"/>
                            </div>
                        </div>
                        <link rel="stylesheet" type="text/css" href="/public/common/webuploader-0.1.5/webuploader.css">
                        <script type="text/javascript" src="/public/common/webuploader-0.1.5/webuploader.js"></script>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span
                                    class="c-red">*</span>展示图片：</label>
                            <div class="col-sm-9 ">
                                <div id="uploader-demo" style="max-width: 300px">
                                    <!--用来存放item-->
                                    <div id="photoList" class="uploader-list">
                                        <?php if(isset($detail['photo'])){?>
                                        <div class="file-item thumbnail"><img width="110" src="/attachs/uploads/<?=$detail['photo']?>"><input type="hidden" value="<?=$detail['photo']?>" name="photo" id="photo">
                                        </div>
                                        <?php }?>
                                    </div>
                                    <div id="photoPicker">选择图片</div>
                                </div>
                            </div>
                        </div>
                        <script>


                            var uploaderphoto = WebUploader.create({
                                auto: true,
                                swf: '/public/admin/Widget/webuploader-0.1.5/Uploader.swf',
                                server: '<?=url("upload.upload/index",['mdl'=>"hotel_photo"])?>',
                                pick: '#photoPicker',
                                resize: false,
                                duplicate: true
                            });

                            $(document).on('click', '.file-item', function () {
                                $(this).remove();
                            });

                            // 当有文件添加进来的时候
                            uploaderphoto.on('fileQueued', function (file) {
                                var $li = $(
                                    '<div id="' + file.id + '" class="file-item thumbnail">' +
                                    '<img>' +
                                    '<input type="hidden" value="" name="photo" id="photo">' +
                                    '<div class="info">' + file.name + '</div>' +
                                    '</div>'
                                    ),
                                    $img = $li.find('img');


                                // $list为容器jQuery实例
                                $("#photoList").html($li);

                                // 创建缩略图
                                // 如果为非图片文件，可以不用调用此方法。
                                // thumbnailWidth x thumbnailHeight 为 100 x 100
                                uploaderphoto.makeThumb(file, function (error, src) {
                                    if (error) {
                                        $img.replaceWith('<span>不能预览</span>');
                                        return;
                                    }

                                    $img.attr('src', src);
                                }, 100, 100);
                            });
                            // 文件上传过程中创建进度条实时显示。
                            uploaderphoto.on('uploadProgress', function (file, percentage) {
                                var $li = $('#' + file.id),
                                    $percent = $li.find('.progress span');

                                // 避免重复创建
                                if (!$percent.length) {
                                    $percent = $('<p class="progress"><span></span></p>')
                                        .appendTo($li)
                                        .find('span');
                                }

                                $percent.css('width', percentage * 100 + '%');
                            });

                            // 文件上传成功，给item添加成功class, 用样式标记上传成功。
                            uploaderphoto.on('uploadSuccess', function (file, response) {
                                $('#' + file.id).addClass('upload-state-done');
                                $("#photo").val(response._raw);
                            });

                            // 文件上传失败，显示上传出错。
                            uploaderphoto.on('uploadError', function (file) {
                                var $li = $('#' + file.id),
                                    $error = $li.find('div.error');

                                // 避免重复创建
                                if (!$error.length) {
                                    $error = $('<div class="error"></div>').appendTo($li);
                                }

                                $error.text('上传失败');
                            });

                            // 完成上传完了，成功或者失败，先删除进度条。
                            uploaderphoto.on('uploadComplete', function (file) {
                                $('#' + file.id).find('.progress').remove();
                            });

                        </script>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right">商品详情：</label>
                            <div style="margin-left: 10px;" class="col-sm-7">
                                <div class="row">
                                    <div style=" display: none;" class="photolist">
                                        <h2>图片资源管理器</h2>
                                        <img onclick="$('.photolist').hide(200);" class="closed" src="/public/admin/img/guanbi.png" />

                                        <div data-type="0" class="content jq_photolist">
                                            <div class="addimg">
                                                <img onclick="$('#file').click();" src="/public/admin/img/add_img.png"  />
                                                <input type="file" name="file" id="file" style="display:none;"/>
                                                <div style=" margin-top: 10px; text-align: center;font-size: 14px; ">添加新图片</div>
                                            </div>

                                        </div>
                                    </div>
                                    <div class="toutiaolt">
                                        <div  class="title">
                                            <h2>
                                                <a id="jq_title" href="javascript:void(0);">商品详情</a>
                                            </h2>
                                        </div>
                                        <div class="duanluo">
                                        </div>
                                        <div class="button">
                                            <button type="button" class="jq_dl_add btn btn-outline btn-default">新增段落</button>
                                            <!--<button mini="submit" for="toutiao_form" type="button" class="btn btn-outline btn-primary">发布文章</button>-->
                                            <button type="button" class="jq_yl_show btn btn-outline btn-info">预览</button>
                                        </div>
                                    </div>
                                    <div class="toutiaort">
                                        <div  id="jq_title_setting"  class="title_form">
                                            <div class="col-md-12">
                                                <div class="ibox-content">
                                                    <h2 style="margin-top: 80%" class="jq_dl_add">请添加先一个段落</h2>
                                                </div>
                                            </div>
                                        </div>
                                        <div style="display: none;" id="jq_yulang_setting" class="yulang">
                                        </div>
                                        <div  style="display: none;" id="jq_duanluo_setting"  class="title_form">
                                            <div class="col-md-12">
                                                <div class="ibox-content">
                                                    <h2> 段落管理 </h2>
                                                    <div class="alert alert-info">
                                                        段落如果有文章则添加文章，有图片则添加图片，不能两者同时为空！
                                                    </div>
                                                    <form role="form" class="form-horizontal m-t">
                                                        <div class="form-group">
                                                            <label class="col-sm-3 control-label">文字：</label>
                                                            <div class="col-sm-9">
                                                                <textarea rows="10" id="dlcontent" class="form-control"></textarea>
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="col-sm-3 control-label">图片：</label>
                                                            <div class="col-sm-9">

                                                                <img width="150" height="150" id="dl_show_photo" src="/public/admin/img/add_img.png" />
                                                                <input type="hidden" name="dlphoto" id="dlphoto" />
                                                            </div>
                                                        </div>
                                                        <button type="button" id="jq_dlsetting"  class="btn btn-block btn-outline btn-primary">确定设置</button>
                                                    </form>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="clearfix form-actions">
                            <div class="col-md-offset-3 col-md-9">
                                <button mini="submit" for="form-create" class="btn btn-info" type="button">
                                    <i class="ace-icon fa fa-check bigger-110"></i>
                                    保存
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script id="imgitemtpl" type="text/html">
    <div class="imgitem">
        <img src="/attachs/uploads/{{d.img}}"  />
        <div class="action">
            <button type="button" data-photo="{{d.img}}"  class="jq_yes_imgitem btn btn-outline btn-primary">选择</button>
            <button type="button"  class="jq_delete_imgitem btn btn-outline btn-danger">删除</button>
        </div>
    </div>
</script>
<script id="yltpl" type="text/html">
    <div class="title">
        <a  href="javascript:void(0);">详情页预览</a>
    </div>
    <div class="content">
        {{# for(var i = 0, len = d.contentdata.length; i < len; i++){ }}
        <div  class="dl">
            {{# if(d.contentdata[i].pic){ }}
            <img src="/attachs/uploads/{{d.contentdata[i].pic}}"/>
            {{# } }}
            {{# if(d.contentdata[i].content){ }}
            {{d.contentdata[i].content}}
            {{# } }}
        </div>
        {{# } }}
    </div>
</script>
<script id="dlitemtpl" type="text/html">
    <div  class="item">
        <a  href="javascript:void(0);" class="jq_delete_dl"><img width="30" height="30" src="/public/admin/img/delete.png" /></a>
        <div class="jq_item" data-id="{{d.id}}" style="width: 100%;height: 100%;">
            <div class="lt">
                <img id="dl_show_pic_{{d.id}}" width="80" height="80" src="/public/admin/img/wenben.png" />
            </div>
            <div id="dl_show_content_{{d.id}}" class="rt">
            </div>
            <input type="hidden" name="dl[{{d.id}}][photo]" id="dl_photo_{{d.id}}"/>
            <input type="hidden" name="dl[{{d.id}}][content]" id="dl_content_{{d.id}}"/>
        </div>
    </div>
</script>
<script>
    var day = '<?=date("Y-m-d",time());?>';
    var imgurl = '<?php echo IMG_URL;?>';
    var uploadUrl = '<?=url("upload.upload/index",["mdl"=>"toutiao_photo"])?>';
</script>
<script src="/public/admin/js/goods.js"></script>





















